<template>
  <div class="box">
    <div class="box__ghost">
      <div class="symbol" />
      <div class="symbol" />
      <div class="symbol" />
      <div class="symbol" />
      <div class="symbol" />
      <div class="symbol" />
      <div class="box__ghost-container">
        <div class="box__ghost-eyes" :style="moveTransform">
          <div class="box__eye-left" />
          <div class="box__eye-right" />
        </div>
        <div class="box__ghost-bottom">
          <div />
          <div />
          <div />
          <div />
          <div />
        </div>
      </div>
      <div class="box__ghost-shadow" />
    </div>
    <div class="box__description">
      <div class="box__description-container">
        <div class="box__description-title">403错误！</div>
        <div class="box__description-text text-color-regular">
          您暂时无权限访问该页面，请联系管理员
        </div>
      </div>
      <a href="#" class="box__button" @click.prevent="backIndex">返回</a>
    </div>
  </div>
</template>

<script setup>
import { computed, onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
const xAxis = ref(0);
const yAxis = ref(0);
const moveTransform = computed(() => {
  return { transform: `translate(${xAxis}%,${-yAxis}%)` };
});
const router = useRouter();

const eyeMove = () => {
  const pageX = document.body.clientWidth;
  const pageY = document.body.clientHeight;
  let mouseY = 0;
  let mouseX = 0;

  document.body.addEventListener('mousemove', () => {
    mouseY = event.pageY;
    yAxis.value = ((pageY / 2 - mouseY) / pageY) * 300;
    mouseX = event.pageX / -pageX;
    xAxis.value = -mouseX * 100 - 100;
  });
};
const backIndex = () => {
  router.go(-2);
};
onMounted(() => {
  eyeMove();
});
</script>

<style lang="scss" scoped>
.box {
  width: 350px;
  padding: 60px 50px;
  margin: 0 auto;
  border-radius: 20px;
}

.box .box__ghost {
  position: relative;
  padding: 15px 25px 25px;
}

.box .box__ghost .symbol:nth-child(1) {
  opacity: 0.2;
  animation: shine 4s ease-in-out 3s infinite;
}

.box .box__ghost .symbol:nth-child(1)::before,
.box .box__ghost .symbol:nth-child(1)::after {
  position: absolute;
  bottom: 65px;
  left: 0;
  width: 12px;
  height: 4px;
  content: '';
  background: $color-primary;
  border-radius: 5px;
}

.box .box__ghost .symbol:nth-child(1)::before {
  transform: rotate(45deg);
}

.box .box__ghost .symbol:nth-child(1)::after {
  transform: rotate(-45deg);
}

.box .box__ghost .symbol:nth-child(2) {
  position: absolute;
  top: 30px;
  left: -5px;
  width: 18px;
  height: 18px;
  border: 4px solid;
  border-color: $color-primary;
  border-radius: 50%;
  opacity: 0.2;
  animation: shine 4s ease-in-out 1.3s infinite;
}

.box .box__ghost .symbol:nth-child(3) {
  opacity: 0.2;
  animation: shine 3s ease-in-out 0.5s infinite;
}

.box .box__ghost .symbol:nth-child(3)::before,
.box .box__ghost .symbol:nth-child(3)::after {
  position: absolute;
  top: 5px;
  left: 40px;
  width: 12px;
  height: 4px;
  content: '';
  background: $color-primary;
  border-radius: 5px;
}

.box .box__ghost .symbol:nth-child(3)::before {
  transform: rotate(90deg);
}

.box .box__ghost .symbol:nth-child(3)::after {
  transform: rotate(180deg);
}

.box .box__ghost .symbol:nth-child(4) {
  opacity: 0.2;
  animation: shine 6s ease-in-out 1.6s infinite;
}

.box .box__ghost .symbol:nth-child(4)::before,
.box .box__ghost .symbol:nth-child(4)::after {
  position: absolute;
  top: 10px;
  right: 30px;
  width: 15px;
  height: 4px;
  content: '';
  background: $color-primary;
  border-radius: 5px;
}

.box .box__ghost .symbol:nth-child(4)::before {
  transform: rotate(45deg);
}

.box .box__ghost .symbol:nth-child(4)::after {
  transform: rotate(-45deg);
}

.box .box__ghost .symbol:nth-child(5) {
  position: absolute;
  top: 40px;
  right: 5px;
  width: 12px;
  height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  opacity: 0.2;
  animation: shine 1.7s ease-in-out 7s infinite;
}

.box .box__ghost .symbol:nth-child(6) {
  opacity: 0.2;
  animation: shine 2s ease-in-out 6s infinite;
}

.box .box__ghost .symbol:nth-child(6)::before,
.box .box__ghost .symbol:nth-child(6)::after {
  position: absolute;
  right: -5px;
  bottom: 65px;
  width: 15px;
  height: 4px;
  content: '';
  background: $color-primary;
  border-radius: 5px;
}

.box .box__ghost .symbol:nth-child(6)::before {
  transform: rotate(90deg);
}

.box .box__ghost .symbol:nth-child(6)::after {
  transform: rotate(180deg);
}

.box .box__ghost .box__ghost-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  background: $color-primary;
  border-radius: 100px 100px 0 0;
  animation: upndown 3s ease-in-out infinite;
}

.box .box__ghost .box__ghost-container .box__ghost-eyes {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 70px;
  height: 12px;
}

.box .box__ghost .box__ghost-container .box__ghost-eyes .box__eye-left {
  position: absolute;
  left: 0;
  width: 12px;
  height: 12px;
  margin: 0 10px;
  background: #fff;
  border-radius: 50%;
}

.box .box__ghost .box__ghost-container .box__ghost-eyes .box__eye-right {
  position: absolute;
  right: 0;
  width: 12px;
  height: 12px;
  margin: 0 10px;
  background: #fff;
  border-radius: 50%;
}

.box .box__ghost .box__ghost-container .box__ghost-bottom {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  display: flex;
}

.box .box__ghost .box__ghost-container .box__ghost-bottom div {
  position: relative;
  top: -10px;
  flex-grow: 1;
  height: 20px;
  background-color: $color-primary;
  border-radius: 100%;
}

.box .box__ghost .box__ghost-container .box__ghost-bottom div:nth-child(2n) {
  top: -12px;
  margin: 0 -0;
  background: transparent;
  border-top: 15px solid #fff;
}

.box .box__ghost .box__ghost-shadow {
  height: 20px;
  margin: 0 auto;
  border-radius: 50%;
  box-shadow: 0 50px 15px 5px $color-primary;
  animation: smallnbig 3s ease-in-out infinite;
}

.box .box__description {
  margin: 0 auto;
  margin-top: 70px;
}

.box .box__description .box__description-container {
  width: 200px;
  margin: 0 auto;
  font-size: 16px;
  color: #fff;
  text-align: center;
}

.box .box__description .box__description-container .box__description-title {
  font-size: 24px;
  color: $color-primary;
  letter-spacing: 0.5px;
}

.box .box__description .box__description-container .box__description-text {
  margin-top: 20px;
  line-height: 20px;
}

.box .box__description .box__button {
  position: relative;
  display: block;
  height: 50px;
  padding: 0 70px;
  margin-top: 25px;
  overflow: hidden;
  font-size: 18px;
  line-height: 50px;
  color: #fff;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  background: $color-danger;
  border: 1px solid transparent;
  border-radius: 50px;
  transition: background 0.5s ease;
}

.box .box__description .box__button::before {
  position: absolute;
  bottom: -25px;
  left: 0;
  width: 20px;
  height: 100px;
  content: '';
  background: #fff;
  border: 2px solid #fff;
  transition: transform 0.5s ease;
  transform: translateX(-50px) rotate(45deg);
}

.box .box__description .box__button:hover {
  background: $color-primary;
  border-color: $color-primary;
}

.box .box__description .box__button:hover::before {
  transform: translateX(250px) rotate(45deg);
}

@keyframes upndown {
  0% {
    transform: translateY(5px);
  }

  50% {
    transform: translateY(15px);
  }

  100% {
    transform: translateY(5px);
  }
}

@keyframes smallnbig {
  0% {
    width: 90px;
  }

  50% {
    width: 100px;
  }

  100% {
    width: 90px;
  }
}

@keyframes shine {
  0% {
    opacity: 0.2;
  }

  25% {
    opacity: 0.1;
  }

  50% {
    opacity: 0.2;
  }

  100% {
    opacity: 0.2;
  }
}
</style>
